﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using University.Workshop.WinApp.AppointmentFolder;
using University.Workshop.Model;
using University.Workshop.WinApp.CashManagementFolder;
using University.Workshop.WinApp.AmbulanceFolder;
using University.Workshop.WinApp.RatesAndGroupsFolder;

namespace University.Workshop.WinApp
{
    public partial class PrincipalForm : Form
    {
        private LoginInterface loginForm;
        private RegisterAppointmentView appointmentForm;
        private MedicineRegister medicineRegisterForm;
        private UserRegistration userRegistrationForm;
        private PatientRegister patientRegisterForm;
        private CalendarForm calendarForm;
        private ConsultationRegister consultationRegisterForm;
        private SearchPatient searchPatientForm;
        private RegisterMedicalSupplies registermedicalsuppliesform;
        private GetAppointmentesTodayByDoctor GetAppointments;
        private UpdateAppointmentDate updateAppointementDate;
        private GetPosponedAppointments getposponedappointments;
        private AppointmentReminder appointmentsReminder;
        private MedicineReportsView medicineReports;
        private Hospitalization.HospitalizationForm hospitalizationForm;
        private CheckupRegister checkupRegisterForm;
        private CashManagementForm cashManagementForm;
        private HospitalizationFolder.SearchHospitalizationForm searchHospitalization;
        private NewAmbulanceView newAmbulanceView;
        private AmbulanceListView ambulanceListView;
        private RatesGroupsForm ratesGroupsForm;
        

        public User userLogged;

        public void AddChildForm(Form childForm)
        {
            childForm.MdiParent = this;
            childForm.Show();
        }

        public PrincipalForm()
        {
            InitializeComponent();

            this.Location = Screen.PrimaryScreen.WorkingArea.Location;
            this.Size = Screen.PrimaryScreen.WorkingArea.Size;
            toolStripDropDownButton9.Visible = false;

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void logInToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.loginForm = new LoginInterface(this);
            AddChildForm(loginForm);
        }

        private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LogOut();
        }

        private void LogOut()
        {
            logOutToolStripMenuItem.Enabled = false;
            logInToolStripMenuItem.Enabled = true;
            toolStripDropDownButton1.Visible = false;
            toolStripDropDownButton2.Visible = false;
            toolStripDropDownButton3.Visible = false;
            toolStripDropDownButton4.Visible = false;
            toolStripDropDownButton5.Visible = false;
            toolStripDropDownButton6.Visible = false;
            toolStripDropDownButton7.Visible = false;
            toolStripCashManagement.Visible = false;
            toolStripDropDownButton9.Visible = false;


        }

        public void LogIn(User user)
        {
            userLogged = user;
            if (userLogged.Role == "Doctor")
            {
                logOutToolStripMenuItem.Enabled = true;
                logInToolStripMenuItem.Enabled = false;
                toolStripDropDownButton1.Visible = false;
                toolStripDropDownButton2.Visible = true;
                appointmentsTodayToolStripMenuItem.Visible = true;
                newAppointmentToolStripMenuItem.Visible = false;
                calendarToolStripMenuItem.Visible = false;
                toolStripDropDownButton3.Visible = true;
                registerNewPatienToolStripMenuItem.Visible = false;
                searchPatientToolStripMenuItem.Visible = true;
                toolStripDropDownButton4.Visible = false;
                toolStripDropDownButton6.Visible = false;
                toolStripDropDownButton5.Visible = true;
                appointementsReminderToolStripMenuItem.Visible = false;
                registerHospitalizationToolStripMenuItem.Visible = false;
                registerCheckupToolStripMenuItem.Visible = true;
                toolStripDropDownButton7.Visible = false;
                toolStripCashManagement.Visible = false;
                toolStripDropDownButton9.Visible = false;

            }
            else {
                if (userLogged.Role == "Secretaria")
                {
                    logOutToolStripMenuItem.Enabled = true;
                    logInToolStripMenuItem.Enabled = false;
                    toolStripDropDownButton1.Visible = false;
                    toolStripDropDownButton2.Visible = true;
                    appointmentsTodayToolStripMenuItem.Visible = false;
                    newAppointmentToolStripMenuItem.Visible = true;
                    calendarToolStripMenuItem.Visible = true;
                    toolStripDropDownButton3.Visible = true;
                    registerNewPatienToolStripMenuItem.Visible = true;
                    searchPatientToolStripMenuItem.Visible = true;
                    toolStripDropDownButton4.Visible = false;
                    toolStripDropDownButton6.Visible = true;
                    toolStripDropDownButton5.Visible = false;
                    appointementsReminderToolStripMenuItem.Visible = true;
                    toolStripDropDownButton7.Visible = true;
                    registerHospitalizationToolStripMenuItem.Visible = true;
                    registerCheckupToolStripMenuItem.Visible = false;
                    toolStripCashManagement.Visible = true;
                    toolStripDropDownButton9.Visible = true;

                }
                else {
                    if (userLogged.Role == "Admin")
                    {
                        logOutToolStripMenuItem.Enabled = true;
                        logInToolStripMenuItem.Enabled = false;
                        toolStripDropDownButton1.Visible = true;
                        toolStripDropDownButton2.Visible = false;
                        appointmentsTodayToolStripMenuItem.Visible = true;
                        newAppointmentToolStripMenuItem.Visible = false;
                        calendarToolStripMenuItem.Visible = false;
                        toolStripDropDownButton3.Visible = false;
                        registerNewPatienToolStripMenuItem.Visible = false;
                        searchPatientToolStripMenuItem.Visible = true;
                        toolStripDropDownButton4.Visible = false;
                        toolStripDropDownButton6.Visible = false;
                        toolStripDropDownButton5.Visible = false;
                        appointementsReminderToolStripMenuItem.Visible = false;
                        registerHospitalizationToolStripMenuItem.Visible = false;
                        registerCheckupToolStripMenuItem.Visible = false;
                        toolStripDropDownButton7.Visible = false;
                        toolStripCashManagement.Visible = false;
                        toolStripDropDownButton9.Visible = false;


                    }
                    else {
                        if (userLogged.Role == "Farmaceuta")
                        {
                            logOutToolStripMenuItem.Enabled = true;
                            logInToolStripMenuItem.Enabled = false;
                            toolStripDropDownButton1.Visible = false;
                            toolStripDropDownButton2.Visible = false;
                            appointmentsTodayToolStripMenuItem.Visible = true;
                            newAppointmentToolStripMenuItem.Visible = false;
                            calendarToolStripMenuItem.Visible = false;
                            toolStripDropDownButton3.Visible = false;
                            registerNewPatienToolStripMenuItem.Visible = false;
                            searchPatientToolStripMenuItem.Visible = true;
                            toolStripDropDownButton4.Visible = true;
                            toolStripDropDownButton6.Visible = false;
                            toolStripDropDownButton5.Visible = false;
                            appointementsReminderToolStripMenuItem.Visible = false;
                            registerHospitalizationToolStripMenuItem.Visible = false;
                            MedicinesLowInitialView medicinesLowInitialView = new MedicinesLowInitialView();
                            medicinesLowInitialView.Show();
                            MedicinesExpiredView medicinesExpiredInitialView = new MedicinesExpiredView();
                            medicinesExpiredInitialView.Show();
                            registerCheckupToolStripMenuItem.Visible = false;
                            toolStripDropDownButton7.Visible = false;
                            toolStripCashManagement.Visible = false;
                            toolStripDropDownButton9.Visible = false;


                        }
                    }
                }
            }

             
        }

        private void newAppointmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            appointmentForm = new RegisterAppointmentView();
            AddChildForm(appointmentForm);
        }

        private void rEgisterNewMedicineToolStripMenuItem_Click(object sender, EventArgs e)
        {
            medicineRegisterForm = new MedicineRegister();
            AddChildForm(medicineRegisterForm);
        }

        private void registerNewUserToolStripMenuItem_Click(object sender, EventArgs e)
        {
            userRegistrationForm = new UserRegistration();
            AddChildForm(userRegistrationForm);
        }

        private void registerNewPatienToolStripMenuItem_Click(object sender, EventArgs e)
        {
            patientRegisterForm = new PatientRegister();
            AddChildForm(patientRegisterForm);
        }

        private void calendarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            calendarForm = new CalendarForm();
            AddChildForm(calendarForm);
        }

        private void calendarToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            calendarForm = new CalendarForm();
            AddChildForm(calendarForm);
        }

        private void searchPatientToolStripMenuItem_Click(object sender, EventArgs e)
        {
            searchPatientForm = new SearchPatient();
            AddChildForm(searchPatientForm);
        }

        private void registerNewConsultationToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            consultationRegisterForm = new ConsultationRegister();
            AddChildForm(consultationRegisterForm);
        }

        private void registerNewConsultationToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            consultationRegisterForm = new ConsultationRegister();
            AddChildForm(consultationRegisterForm);
        }

        private void registrarSalidaDeInsumosMedicosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            registermedicalsuppliesform = new RegisterMedicalSupplies();
            AddChildForm(registermedicalsuppliesform);

        }

        private void registerMedicalSuppliesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            registermedicalsuppliesform = new RegisterMedicalSupplies();
            AddChildForm(registermedicalsuppliesform);
        }

        private void PrincipalForm_Load(object sender, EventArgs e)
        {

        }

        private void appointmentsTodayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GetAppointments = new GetAppointmentesTodayByDoctor(userLogged);
            AddChildForm(GetAppointments);
        }

        private void updateAppointmentDateToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            updateAppointementDate = new UpdateAppointmentDate();
            AddChildForm(updateAppointementDate);
        }

        private void appointmentsCancelledToolStripMenuItem_Click(object sender, EventArgs e)
        {
            getposponedappointments = new GetPosponedAppointments(userLogged);
            AddChildForm(getposponedappointments);
        }

        private void appointementsReminderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            appointmentsReminder = new AppointmentReminder(userLogged);
            AddChildForm(appointmentsReminder);
        }

        private void medicineReportsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            medicineReports = new MedicineReportsView(userLogged);
            AddChildForm(medicineReports);
        }

        private void registerToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void registerHospitalizationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            hospitalizationForm = new Hospitalization.HospitalizationForm();
            AddChildForm(hospitalizationForm);
        }

        private void posponedAppointmentsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            getposponedappointments = new GetPosponedAppointments(userLogged);
            AddChildForm(getposponedappointments);
        }

        private void registerCheckupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            checkupRegisterForm = new CheckupRegister();
            AddChildForm(checkupRegisterForm);
        }

        private void toolStripDropDownButton8_Click(object sender, EventArgs e)
        {
            
        }

        private void registerAPaymentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            cashManagementForm = new CashManagementForm();
            AddChildForm(cashManagementForm);
        }

        private void searchHospitalizationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            searchHospitalization = new HospitalizationFolder.SearchHospitalizationForm();
            AddChildForm(searchHospitalization);
        }

        private void registerToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            newAmbulanceView = new NewAmbulanceView();
            AddChildForm(newAmbulanceView);
        }

        private void modifyDeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ambulanceListView = new AmbulanceListView();
            AddChildForm(ambulanceListView);
        }

        private void ratesAndGroupsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ratesGroupsForm = new RatesGroupsForm();
            AddChildForm(ratesGroupsForm);
        }

     

      
    }
}
